<template>
	<view>
		<login-component ref="loginComponent" v-if="showLogin" @show="show" @updateUserInfo="updateUserInfo"></login-component>
		<register-component v-if="showRegister" @show="show" @updateUserInfo="updateUserInfo"></register-component>
	</view>
</template>

<script>
	import LoginComponent from '@/pages/user/auth/login/login'
	import RegisterComponent from '@/pages/user/auth/register/register'
	export default {
		data() {
			return {
				showLogin: true,
				showRegister: false,
				inviteCode: ''
			};
		},
		components: {
			LoginComponent,
			RegisterComponent
		},
		onLoad(params) {
			//console.log(params);
			this.inviteCode = params.scene ? params.scene: '';
		},
		onShow() {
			this.$refs.loginComponent.setInviteCode(this.inviteCode);
		},
		methods: {
			updateUserInfo(userInfo) {
				this.$store.commit('setGlobalUserInfo', userInfo)
			},
			show(what) {
				if (what=='login') {
					this.showLogin = true
					this.showRegister = false
					uni.setNavigationBarTitle({
						title: '登录'
					});
				} else {
					this.showLogin = false
					this.showRegister = true	
					uni.setNavigationBarTitle({
						title: '注册'
					});
				}
			}
		}
	}
</script>

<style>
</style>
